var password0 = document.getElementById("password0").value;
var password1 = document.getElementById("password1").value;
var password2 = document.getElementById("password2").value;
var password = password1;
if (password1 != password2)
{
alert("The passwords don't match");
return false;
}
if (password.length == 0)
{
alert("You cannot have a blank password");
return false;
}
var res = opener.su_post_url_server_secure(
"change_password.php",
"username=" + detail.id +
"&password=" + encodeURIComponent(password0) +
"&newpassword=" + encodeURIComponent(password));
if (res.status == 1)
{
alert("The stumbleupon.com server is currently down.\nPlease try again, and if you are still having difficulties,\ngo to http://www.stumbleupon.com/feedback.php to report the problem\nError : " + res.error + "\nStatus : " + res.status);
return false;
}
if (res.status != 200)
{
alert("The stumbleupon.com server is currently down.\nPlease try again, and if you are still having difficulties,\ngo to http://www.stumbleupon.com/feedback.php to report the problem\nError : " + res.error + "\nStatus : " + res.status);
return false;
}
var s = res.response;
try {
if (opener.su_log_communication)
opener.su_log("response change_password.php", s);
} catch (e) {}
// Split the response it username and pass
var ss;
if (s)
{
ss = s.split("\n")[0].split(" ");
}
else if (s != "")
{
alert("The stumbleupon.com server is currently down.\nPlease try again, and if you are still having difficulties,\ngo to http://www.stumbleupon.com/feedback.php to report the problem\nError : incomplete response");
return false;
}
else
{
ss = new Array();
ss[0] = "";
}
if (ss[0] == "ERROR")
{
var ps = window.opener.su_get_service(
"@mozilla.org/embedcomp/prompt-service;1",
"nsIPromptService");
var msg = "An unknown error occurred trying to change your password.\r\n\r\nPlease try a different password.";
if(ss[1])
{
if(ss[1] == "INCORRECT_PASSWORD")
{
var out = ps.confirmEx(
window,
"StumbleUpon Password Recovery",
"The password you supplied was incorrect.\r\n\r\nWould you like to recover your username/password?",